<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends CommonController {
	//前台首页
    public function index()
    {
    	//print_r($_SESSION);
        //公共显示变量
        $this->public_xianshi();

        //选择课程
        $grades = M('grade')->where(array('parent_id'=>0))->select();
        $this->assign('grades',$grades);

        $name = I('get.name');
        $this->assign('name',$name);
        if ($name == '艺术兴趣') {
            //科目
            $kemus = M('grade')->where(array('parent_id'=>2))->select();
            $this->assign('kemus',$kemus);
        }else {
            //科目
            $kemus = M('grade')->where(array('parent_id'=>1))->select();
            $this->assign('kemus',$kemus);
        }

        //取出文化课程
        $wenhua = M('grade')->where(array('parent_id'=>1))->select();
        $this->assign('wenhua',$wenhua);
        //高中
        $gaoyi = M('grade')->where(array('parent_id'=>5))->select();
        $this->assign('gaoyi',$gaoyi);
        //初中
        $chuyi = M('grade')->where(array('parent_id'=>4))->select();
        $this->assign('chuyi',$chuyi);
        //小学
        $xiaoyi = M('grade')->where(array('parent_id'=>3))->select();
        $this->assign('xiaoyi',$xiaoyi);
        //语言 
        $lxyy = M('grade')->where(array('parent_id'=>6))->select();
        $this->assign('lxyy',$lxyy);

        //取出艺术课程
        $yishu = M('grade')->where(array('parent_id'=>2))->select();
        $this->assign('yishu',$yishu);
        //乐器
        $yueqi = M('grade')->where(array('parent_id'=>32))->select();
        $this->assign('yueqi',$yueqi);
        //声乐
        $shengyue = M('grade')->where(array('parent_id'=>33))->select();
        $this->assign('shengyue',$shengyue);
        //舞蹈
        $wudao = M('grade')->where(array('parent_id'=>34))->select();
        $this->assign('wudao',$wudao);
        //书法
        $shufa = M('grade')->where(array('parent_id'=>35))->select();
        $this->assign('shufa',$shufa);
        //绘画
        $huihua = M('grade')->where(array('parent_id'=>36))->select();
        $this->assign('huihua',$huihua);
        //媒体艺术
        $meiti = M('grade')->where(array('parent_id'=>37))->select();
        $this->assign('meiti',$meiti);
        //雕塑
        $diaoshu = M('grade')->where(array('parent_id'=>38))->select();
        $this->assign('diaoshu',$diaoshu);
        //鉴赏
        $jianshang = M('grade')->where(array('parent_id'=>39))->select();
        $this->assign('jianshang',$jianshang);
        //戏剧
        $xiju = M('grade')->where(array('parent_id'=>40))->select();
        $this->assign('xiju',$xiju);

        //文化课程
        //自动获取城市 小学 取最多5条
        $city_info = I('get.newcity')?I('get.newcity'):'广州';

        //小学
        $sql = "select t1.id,t1.sfz_name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.grades,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades='小学' and t1.city='{$city_info}' order by t1.create_time desc limit 5";
        $xx = M()->query($sql);
        $this->assign('xx',$xx);
        //初中
        $sql = "select t1.id,t1.sfz_name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.grades,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades='初中' and t1.city='{$city_info}' order by t1.create_time desc limit 5";
        $cz = M()->query($sql);
        $this->assign('cz',$cz);
        //高中
        $sql = "select t1.id,t1.sfz_name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.grades,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades='高中' and t1.city='{$city_info}' order by t1.create_time desc limit 5";
        $gz = M()->query($sql);
        $this->assign('gz',$gz);
        //语言
        $sql = "select t1.id,t1.sfz_name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.grades,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades='语言' and t1.city='{$city_info}' order by t1.create_time desc limit 5";
        $yy = M()->query($sql);
        $this->assign('yy',$yy);

        //艺术课程
        //乐器
        $sql = "select t1.id,t1.sfz_name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades='乐器' and t1.city='{$city_info}' order by t1.create_time desc limit 5";
        $yq = M()->query($sql);
        $this->assign('yq',$yq);
        //声乐
        $sql = "select t1.id,t1.sfz_name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.grades,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades='声乐' and t1.city='{$city_info}' order by t1.create_time desc limit 5";
        $sy = M()->query($sql);
        $this->assign('sy',$sy);
        //舞蹈
        $sql = "select t1.id,t1.sfz_name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.grades,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades='舞蹈' and t1.city='{$city_info}' order by t1.create_time desc limit 5";
        $wd = M()->query($sql);
        $this->assign('wd',$wd);
        //书法
        $sql = "select t1.id,t1.sfz_name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.grades,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades='书法' and t1.city='{$city_info}' order by t1.create_time desc limit 5";
        $sf = M()->query($sql);
        $this->assign('sf',$sf);

        $this->display();
    }

    //家长指南
    public function jiazhang_zn()
    {
        //公共显示变量
        $this->public_xianshi();

        $this->display();
    }

    //老师指南
    public function laoshi_zn()
    {
        //公共显示变量
        $this->public_xianshi();

        $this->display();
    }

    //关于平台
    public function about()
    {
        //公共显示变量
        $this->public_xianshi();

        $this->display();
    }


}